<?php if(!defined('BASEPATH')) exit('No direct script allowed');

class mdl_openservice extends CI_Model{
	
	function __construct()
	{
		parent::__construct();
	}
	
	function get_item($lim=0, $num=0,$arr_where='')
	{
		$this->db->flush_cache();
		$this->db->select('*');
		$this->db->from('tservices');
		if ($arr_where!=''){
			$this->db->where($arr_where);
		}
		$this->db->order_by("serviceid", "asc");
		if ($lim!=0){
			$this->db->limit($lim,$num);
		}
		return $this->db->get();
	}
	
	function get_countitem($arr_where=''){
		$this->db->flush_cache();
		$this->db->select('*');
		$this->db->from('tusers');
		if ($arr_where!=''){
			$this->db->where($arr_where);
		}
		return  $this->db->count_all_results();
	}
	
	function getItemById($id)
	{
		$this->db->flush_cache();
		$this->db->where('userid', $id);
		return $this->db->get('users');
		
	}
/*
	function insert($data)
	{
		$this->db->flush_cache();
		$this->db->set('username', $data['username']); 
		$this->db->set('password', $data['password']); 
		$this->db->set('level_id', $data['level_id']); 

		
        $result = $this->db->insert('users');
		
		//$result=$this->db->insert('users', $data);
		if($result) {
			return TRUE;
		}else {
			return FALSE;
		}
	} */
	
	function updateagreetoc($username)
	{
		
		$this->db->flush_cache();
	//	$this->db->set('userid', $data['userid']); 
//$this->db->set('username', $data['username']); 
$this->db->set('agreetocstatus', '1'); 
//$this->db->set('level_id', $data['level_id']); 

		$this->db->where('username', $username);
		//$result=$this->db->update('tusers', $data);
		$result=$this->db->update('tusers');
		
		if($result) {
			return TRUE;
		}else {
			return FALSE;
		}
	} 
/*	
	function delete($id)
	{
		
		$this->db->flush_cache();
		$this->db->where('userid', $id);
		$result = $this->db->delete('users');
		
		if($result) {
			return TRUE;
		}else {
			return FALSE;
		}
		
	}
	*/
}
